package com.leyou.order.interceptors;

import com.leyou.order.config.JwtProperties;
import com.leyou.order.task.PrivilegeTokenHolder;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PrivilegeInterceptor implements RequestInterceptor {
    @Autowired
    private PrivilegeTokenHolder tokenHolder;
    @Autowired
    private JwtProperties props;
    @Override
    public void apply(RequestTemplate template){
        String token = tokenHolder.getToken();
        template.header(props.getApp().getHeaderName(),token);
    }
}
